package com.bjpowernode.controller;

import com.bjpowernode.beans.Stu;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/stu")
public class StuController {
    @RequestMapping("add")
    public String addView() {
        return "stu/add";
    }

    @RequestMapping("add.do")
    //前端传递参数的时候无序填写stu形参名称，直接写属性名称即可
    //【正确写法】
    /*
    <p>id:<input name="id" type="text"></p>
    <p>name:<input name="name" type="text"></p>
    <p>sex:<input name="sex" type="text"></p>
     */
    //添加形参名称会无法查找【错误写法】
    /*
    <p>id:<input name="stu.id" type="text"></p>
    <p>name:<input name="stu.name" type="text"></p>
    <p>sex:<input name="stu.sex" type="text"></p>
     */
    public String addAction(Stu stu, Model model) {
        System.out.println(stu);
        model.addAttribute("stu", stu);
        return "stu/index";
    }


}
